package de.szut.main;

import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.v4.app.FragmentManager;
import de.szut.database.DatabaseHelper;
import de.szut.entity.Country;
import de.szut.scene.helper.GameMapHelper;
import de.szut.scene.helper.InfectedDotPool;
import de.szut.scene.helper.StorageHelper;
import de.szut.util.Settings;
import org.andengine.engine.Engine;
import org.andengine.engine.camera.ZoomCamera;
import org.andengine.entity.sprite.batch.SpriteBatch;
import org.andengine.entity.text.Text;
import org.andengine.extension.svg.SVGParser;
import org.andengine.extension.svg.adt.SVG;
import org.andengine.extension.svg.exception.SVGParseException;
import org.andengine.extension.svg.opengl.texture.atlas.bitmap.SVGBitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.font.Font;
import org.andengine.opengl.font.FontFactory;
import org.andengine.opengl.texture.ITexture;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.atlas.bitmap.BuildableBitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource;
import org.andengine.opengl.texture.atlas.buildable.builder.BlackPawnTextureAtlasBuilder;
import org.andengine.opengl.texture.atlas.buildable.builder.ITextureAtlasBuilder;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by dzebcuks on 22.08.13.
 */
public class ResourcesManager {
    //---------------------------------------------
    // VARIABLES
    //---------------------------------------------

    private static ResourcesManager instance = null;
    private Engine engine;
    private GameActivity activity;
    private ZoomCamera zoomCamera;
    private VertexBufferObjectManager vbom;
    private FragmentManager fragmentManager;
    private GameMapHelper gameMapHelper;
    private DatabaseHelper dbHelper;
    private StorageHelper storageHelper;
    //---------------------------------------------
    // TEXTURES & TEXTURE REGIONS
    //---------------------------------------------
    // Splash
    private ITextureRegion splashRegion;
    private BitmapTextureAtlas splashTextureAtlas;
    // Game
    private ITextureRegion gameRegionClick;
    private ITextureRegion gameRegion;
    private Bitmap backgroundBitmap;
    private BuildableBitmapTextureAtlas gameTexttureAtlas;
    private BuildableBitmapTextureAtlas gameTexttureAtlasClick;
    private BuildableBitmapTextureAtlas gameTexttureAtlasExtras;
    private BuildableBitmapTextureAtlas hudTextureAtlas;
    private ITextureRegion hud_bg;
    private ITextureRegion hud_button;
    private ITextureRegion hud_view;
    private ITextureRegion hud_view_transp;
    private SVG backgroundClick = null;
    private SVG backgroundGame = null;
    private Font gameMenuFontBlack;
    private Font gameMenuFontWhite;
    private Font gameMenuFontBlackSmall;
    private ITextureRegion infectedDot;
    private ITextureRegion infectedIcon;
    private ITextureRegion controlledIcon;
    private ITextureRegion researchIcon;
    private ITextureRegion newInfectedCountryIcon;
    // Menu
    private ITextureRegion menuRegion_background;
    private ITextureRegion menu_button;
    private BuildableBitmapTextureAtlas menuTexttureAtlas;
    private Text textPlayBtn;
    //Loading
    private Font menuSceneFont;
    private HashMap<String, ArrayList<String>> countryPixelMap;
    private HashMap<String,String> countryCenterPoints;
    private HashMap<String, SpriteBatch> countrieBatches;


    //---------------------------------------------
    // CLASS LOGIC
    //---------------------------------------------

    /**
     * @param engine
     * @param activity
     * @param zoomCamera
     * @param vbom       <br><br>
     *                   We use this method at beginning of game loading,
     *                   to prepare Resources Manager properly,
     *                   setting all needed parameters, so we can latter access them from different
     *                   classes (eg. scenes)
     */
    public static void prepareManager(Engine engine, GameActivity activity, ZoomCamera zoomCamera,
                                      VertexBufferObjectManager vbom, FragmentManager fragmentManager, GameMapHelper gameMapHelper, DatabaseHelper dbHelper, StorageHelper storageHelper) {
        getInstance().engine = engine;
        getInstance().activity = activity;
        getInstance().zoomCamera = zoomCamera;
        getInstance().vbom = vbom;
        getInstance().fragmentManager = fragmentManager;
        getInstance().gameMapHelper = gameMapHelper;
        getInstance().dbHelper = dbHelper;
        getInstance().storageHelper = storageHelper;
    }

    public static ResourcesManager getInstance() {
        if (instance == null) {
            instance = new ResourcesManager();
        }
        return instance;
    }

    public void loadMenuResources() {
        this.loadMenuGraphics();
        this.loadMenuAudio();
        this.loadMenuFonts();
    }

    public void loadGameResources() {
        this.loadGameGraphics();
        this.loadGameFontsBlack();
        this.loadGameFontsBlackSmall();
        this.loadGameFontsWhite();
        this.loadGameAudio();
    }


    private void loadMenuGraphics() {
        AssetManager assetManager = getActivity().getAssets();
        this.menuTexttureAtlas = new BuildableBitmapTextureAtlas(activity.getTextureManager(),
                Settings.MAX_WIDTH, Settings.MAX_HEIGHT, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        try {
            SVG background = SVGParser.parseSVGFromAsset(assetManager, "gfx/menu/" + Settings.MENU_SCREEN);
            SVG button = SVGParser.parseSVGFromAsset(assetManager, "gfx/menu/" + Settings.MENU_BTN);
            menuRegion_background = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(menuTexttureAtlas, background, Settings.RESOLUTION_WIDTH, Settings.RESOLUTION_HEIGHT);
            menu_button = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(menuTexttureAtlas, button, 300, 100);
            this.menuTexttureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
            this.menuTexttureAtlas.load();
        } catch (SVGParseException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

    }

    private void loadMenuAudio() {

    }

    private void loadMenuFonts() {
        FontFactory.setAssetBasePath("font/");
        final ITexture mainFontTexture = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA);

        menuSceneFont = FontFactory.createStrokeFromAsset(activity.getFontManager(), mainFontTexture, activity.getAssets(), "Droid.ttf", 50, true, Color.WHITE, 2, Color.BLACK);
        menuSceneFont.load();
    }

    private void loadGameGraphics() {
        createGameMapClick();
        createGameMap();
        createGameMapExtras();
        createGameMenu();
        loadPixelFromGameMap();
//        this.activity.runOnUpdateThread(new Runnable() {
//            @Override
//            public void run() {
        createCountrySpriteBatches();
//            }
//        });

    }

    public void createGameMapClick() {
        AssetManager assetManager = getActivity().getAssets();
        if (gameTexttureAtlasClick == null) {
            this.gameTexttureAtlasClick = new BuildableBitmapTextureAtlas(activity.getTextureManager(),
                    Settings.MAX_WIDTH, Settings.MAX_HEIGHT, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        }
        try {
            backgroundClick = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.GAME_SCREEN_CLICK);
        } catch (SVGParseException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        gameRegionClick = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(gameTexttureAtlasClick, backgroundClick, Settings.MAX_WIDTH, Settings.MAX_HEIGHT);
        try {
            this.gameTexttureAtlasClick.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
            this.gameTexttureAtlasClick.load();
        } catch (ITextureAtlasBuilder.TextureAtlasBuilderException buildExeption) {
            buildExeption.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

    }

    private void createGameMap() {
        AssetManager assetManager = getActivity().getAssets();
        if (gameTexttureAtlas == null) {
            this.gameTexttureAtlas = new BuildableBitmapTextureAtlas(activity.getTextureManager(),
                    Settings.MAX_WIDTH, Settings.MAX_HEIGHT, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        }
        try {
            backgroundGame = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.GAME_SCREEN);
            gameRegion = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(gameTexttureAtlas, backgroundGame, Settings.MAX_WIDTH, Settings.MAX_HEIGHT);
            this.gameTexttureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
            this.gameTexttureAtlas.load();
        } catch (SVGParseException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    private void createGameMapExtras() {
        AssetManager assetManager = getActivity().getAssets();
        if (gameTexttureAtlasExtras == null) {
            this.gameTexttureAtlasExtras = new BuildableBitmapTextureAtlas(activity.getTextureManager(), Settings.RESOLUTION_WIDTH, Settings.RESOLUTION_HEIGHT, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        }
        try {
            SVG infectedDot = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.INFECTED_DOT);
            SVG infectedIcon = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.INFECTED_ICON);
            SVG controlledUserIcon = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.CONTROLLED_ICON);
            SVG researchIcon = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.RESEARCH_ICON);
            SVG newInfectedCountryIcon = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.NEW_INFECTION_ICON);
            this.researchIcon = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(gameTexttureAtlasExtras, researchIcon, 25, 25);
            this.controlledIcon = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(gameTexttureAtlasExtras, controlledUserIcon, 25, 25);
            this.newInfectedCountryIcon = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(gameTexttureAtlasExtras, newInfectedCountryIcon, 150, 150);
            this.infectedDot = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(gameTexttureAtlasExtras, infectedDot, 3, 3);
            this.infectedIcon = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(gameTexttureAtlasExtras, infectedIcon, 25, 25);
            this.gameTexttureAtlasExtras.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
            this.gameTexttureAtlasExtras.load();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    private void createGameMenu() {
        AssetManager assetManager = getActivity().getAssets();
        if (hudTextureAtlas == null) {
            this.hudTextureAtlas = new BuildableBitmapTextureAtlas(activity.getTextureManager(),
                    Settings.MAX_WIDTH, Settings.MAX_HEIGHT, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        }
        try {
            SVG hudBackground = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.HUD_BACKGROUND);
            SVG hudBtn = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.HUD_BTN);
            SVG hudView = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.HUD_VIEW);
            SVG hudViewTransp = SVGParser.parseSVGFromAsset(assetManager, "gfx/game/" + Settings.HUD_VIEW_TRANSP);
            hud_bg = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(hudTextureAtlas, hudBackground, Settings.RESOLUTION_WIDTH, Settings.RESOLUTION_HEIGHT);
            hud_button = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(hudTextureAtlas, hudBtn, 200, 50);
            hud_view = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(hudTextureAtlas, hudView, 200, 50);
            hud_view_transp = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(hudTextureAtlas, hudViewTransp, 200, 25);
            this.hudTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
            this.hudTextureAtlas.load();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    private void loadGameFontsBlack() {
        FontFactory.setAssetBasePath("font/");
        final ITexture mainFontTexture = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA);

        gameMenuFontBlack = FontFactory.createStrokeFromAsset(activity.getFontManager(), mainFontTexture, activity.getAssets(), "Droid.ttf", 20, true, Color.BLACK, 2, Color.BLACK);
        gameMenuFontBlack.load();

    }

    private void loadGameFontsBlackSmall() {
        FontFactory.setAssetBasePath("font/");
        final ITexture mainFontTexture = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA);

        gameMenuFontBlackSmall = FontFactory.createStrokeFromAsset(activity.getFontManager(), mainFontTexture, activity.getAssets(), "Droid.ttf", 15, true, Color.BLACK, 2, Color.BLACK);
        gameMenuFontBlackSmall.load();

    }

    private void loadGameFontsWhite() {
        FontFactory.setAssetBasePath("font/");
        final ITexture mainFontTexture = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA);

        gameMenuFontWhite = FontFactory.createStrokeFromAsset(activity.getFontManager(), mainFontTexture, activity.getAssets(), "Droid.ttf", 20, true, Color.WHITE, 2, Color.WHITE);
        gameMenuFontWhite.load();
    }

    private void loadGameAudio() {

    }

    public void loadSplashScreen() {
        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/splash/");
        this.splashTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), Settings.RESOLUTION_WIDTH * 2, Settings.RESOLUTION_HEIGHT * 2, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        this.splashRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(splashTextureAtlas, activity, Settings.SPLASH_SCREEN, Settings.RESOLUTION_WIDTH, Settings.RESOLUTION_HEIGHT);
        this.splashTextureAtlas.load();
    }


    private void loadPixelFromGameMap() {
        Bitmap bitmap = gameMapHelper.getGameMapAsBitmap(activity.getAssets());
        if (storageHelper.pixelMapsAreNotCreated()) {
            if (gameMapHelper.calculateMapsPixel(bitmap, dbHelper)) {
                countryPixelMap = gameMapHelper.getCountryMap();
                countryCenterPoints = gameMapHelper.getCountryCenterPoints();
                setBackgroundBitmap(gameMapHelper.getBackgroundBitmap());
                storageHelper.pixelMapsAreCreated(countryPixelMap,countryCenterPoints);
            }
        } else {
            countryPixelMap = new HashMap<String, ArrayList<String>>();
            countryCenterPoints = new HashMap<String, String>();
            storageHelper.loadPixelMapFromPreferences(countryPixelMap);
            storageHelper.loadCountryCenterPointsFromPreferences(countryCenterPoints);
            this.setBackgroundBitmap(bitmap);
        }
    }

    private void createCountrySpriteBatches() {
        if (countrieBatches == null || countrieBatches.isEmpty()) {
            InfectedDotPool pool = new InfectedDotPool(getInfectedDot(), vbom);
            countrieBatches = new HashMap<String, SpriteBatch>();
            for (String key : countryPixelMap.keySet()) {
                Country country = dbHelper.getCountryDao().getCountryByName(key);
                ArrayList<String> countryPixel = countryPixelMap.get(key);
                SpriteBatch spriteBatch = new SpriteBatch(pool.obtainPoolItem().getTextureRegion().getTexture(), countryPixel.size(), vbom);
                spriteBatch.setTag(country.getColor());
                spriteBatch.submit();
                countrieBatches.put(country.getName(), spriteBatch);
            }
        }
    }


    public void unloadSplashScreen() {
        this.splashTextureAtlas.unload();
        this.splashRegion = null;
    }

    public void unloadMenuScreen() {
        this.menuTexttureAtlas.unload();
    }

    public void unloadGameScreen() {
        this.gameTexttureAtlas.unload();
        this.gameTexttureAtlasClick.unload();
        this.gameTexttureAtlasExtras.unload();
        this.hudTextureAtlas.unload();
    }

    public Engine getEngine() {
        return engine;
    }

    //---------------------------------------------
    // GETTERS AND SETTERS
    //---------------------------------------------

    public void setEngine(Engine engine) {
        this.engine = engine;
    }

    public GameActivity getActivity() {
        return activity;
    }

    public void setActivity(GameActivity activity) {
        this.activity = activity;
    }

    public ZoomCamera getZoomCamera() {
        return zoomCamera;
    }

    public void setZoomCamera(ZoomCamera zoomCamera) {
        this.zoomCamera = zoomCamera;
    }

    public VertexBufferObjectManager getVbom() {
        return vbom;
    }

    public void setVbom(VertexBufferObjectManager vbom) {
        this.vbom = vbom;
    }

    public FragmentManager getFragmentManager() {
        return fragmentManager;
    }

    public void setFragmentManager(FragmentManager fragmentManager) {
        this.fragmentManager = fragmentManager;
    }

    public ITextureRegion getSplashRegion() {
        return splashRegion;
    }

    public void setSplashRegion(ITextureRegion splashRegion) {
        this.splashRegion = splashRegion;
    }

    public BitmapTextureAtlas getSplashTextureAtlas() {
        return splashTextureAtlas;
    }

    public void setSplashTextureAtlas(BitmapTextureAtlas splashTextureAtlas) {
        this.splashTextureAtlas = splashTextureAtlas;
    }

    public ITextureRegion getGameRegionClick() {
        return gameRegionClick;
    }

    public void setGameRegionClick(ITextureRegion gameRegionClick) {
        this.gameRegionClick = gameRegionClick;
    }

    public ITextureRegion getMenuRegion_background() {
        return menuRegion_background;
    }

    public void setMenuRegion_background(ITextureRegion menuRegion_background) {
        this.menuRegion_background = menuRegion_background;
    }

    public ITextureRegion getMenu_button() {
        return menu_button;
    }

    public void setMenu_button(ITextureRegion menu_button) {
        this.menu_button = menu_button;
    }

    public Font getMenuSceneFont() {
        return menuSceneFont;
    }

    public void setMenuSceneFont(Font menuSceneFont) {
        this.menuSceneFont = menuSceneFont;
    }

    public ITextureRegion getGameRegion() {
        return gameRegion;
    }

    public void setGameRegion(ITextureRegion gameRegion) {
        this.gameRegion = gameRegion;
    }

    public ITextureRegion getInfectedDot() {
        return infectedDot;
    }

    public void setInfectedDot(ITextureRegion infectedDot) {
        this.infectedDot = infectedDot;
    }

    public Bitmap getBackgroundBitmap() {
        return backgroundBitmap;
    }

    public void setBackgroundBitmap(Bitmap backgroundBitmap) {
        this.backgroundBitmap = backgroundBitmap;
    }

    public ITextureRegion getHud_view_transp() {
        return hud_view_transp;
    }

    public void setHud_view_transp(ITextureRegion hud_view_transp) {
        this.hud_view_transp = hud_view_transp;
    }

    public ITextureRegion getHud_bg() {
        return hud_bg;
    }

    public void setHud_bg(ITextureRegion hud_bg) {
        this.hud_bg = hud_bg;
    }

    public ITextureRegion getHud_button() {
        return hud_button;
    }

    public void setHud_button(ITextureRegion hud_button) {
        this.hud_button = hud_button;
    }

    public ITextureRegion getHud_view() {
        return hud_view;
    }

    public void setHud_view(ITextureRegion hud_view) {
        this.hud_view = hud_view;
    }

    public Font getGameMenuFontBlack() {
        return gameMenuFontBlack;
    }

    public Font getGameMenuFontWhite() {
        return gameMenuFontWhite;
    }

    public BuildableBitmapTextureAtlas getGameTexttureAtlasClick() {
        return gameTexttureAtlasClick;
    }

    public void setGameTexttureAtlasClick(BuildableBitmapTextureAtlas gameTexttureAtlasClick) {
        this.gameTexttureAtlasClick = gameTexttureAtlasClick;
    }

    public BuildableBitmapTextureAtlas getGameTexttureAtlasExtras() {
        return gameTexttureAtlasExtras;
    }

    public void setGameTexttureAtlasExtras(BuildableBitmapTextureAtlas gameTexttureAtlasExtras) {
        this.gameTexttureAtlasExtras = gameTexttureAtlasExtras;
    }

    public BuildableBitmapTextureAtlas getGameTexttureAtlas() {
        return gameTexttureAtlas;
    }

    public void setGameTexttureAtlas(BuildableBitmapTextureAtlas gameTexttureAtlas) {
        this.gameTexttureAtlas = gameTexttureAtlas;
    }

    public GameMapHelper getGameMapHelper() {
        return gameMapHelper;
    }

    public void setGameMapHelper(GameMapHelper gameMapHelper) {
        this.gameMapHelper = gameMapHelper;
    }

    public DatabaseHelper getDbHelper() {
        return dbHelper;
    }

    public void setDbHelper(DatabaseHelper dbHelper) {
        this.dbHelper = dbHelper;
    }

    public HashMap<String, ArrayList<String>> getCountryPixelMap() {
        return countryPixelMap;
    }

    public ITextureRegion getInfectedIcon() {
        return infectedIcon;
    }

    public ITextureRegion getControlledIcon() {
        return controlledIcon;
    }

    public HashMap<String, SpriteBatch> getCountrieBatches() {
        return countrieBatches;
    }

    public Font getGameMenuFontBlackSmall() {
        return gameMenuFontBlackSmall;
    }

    public StorageHelper getStorageHelper() {
        return storageHelper;
    }

    public ITextureRegion getResearchIcon() {
        return researchIcon;
    }

    public HashMap<String, String> getCountryCenterPoints() {
        return countryCenterPoints;
    }

    public ITextureRegion getNewInfectedCountryIcon() {
        return newInfectedCountryIcon;
    }

    public void setNewInfectedCountryIcon(ITextureRegion newInfectedCountryIcon) {
        this.newInfectedCountryIcon = newInfectedCountryIcon;
    }
    // NOT NEEDED ?!
//    public void executePixelLoaderTask() {
//        if (pixelMapsAreNotCreated()) {
//            GameSceneAsyncCallback callback = new GameSceneAsyncCallback() {
//                @Override
//                public boolean calculateGameMapPixel() {
//                    boolean isFinished;
//                    isFinished = gameMapHelper.calculateMapsPixel(gameMapHelper.getGameMapAsBitmap(activity.getAssets()), dbHelper);
//                    return isFinished;
//                }
//            };
//            ParsePixelFromBitmapTask task = new ParsePixelFromBitmapTask();
//            do {
//                if (task.getStatus() != AsyncTask.Status.RUNNING && task.getStatus() != AsyncTask.Status.FINISHED)
//                    task.execute(callback);
//            } while (gameMapHelper.isPixelCalculationCompleted() == false);
//            countryPixelMap = gameMapHelper.getCountryMap();
//            this.setBackgroundBitmap(gameMapHelper.getBackgroundBitmap());
//            pixelMapsAreCreated();
//        } else {
//            countryPixelMap = new HashMap<String, ArrayList<String>>();
//            loadPixelMapFromPreferences();
//            this.setBackgroundBitmap(gameMapHelper.getGameMapAsBitmap(activity.getAssets()));
//        }
//    }
//    public class ParsePixelFromBitmapTask extends AsyncTask<GameSceneAsyncCallback, Integer, Boolean> {
//        GameSceneAsyncCallback[] params;
//        boolean isFinished = false;
//
//        public ParsePixelFromBitmapTask() {
//        }
//
//        @Override
//        protected Boolean doInBackground(GameSceneAsyncCallback... params) {
//            Log.i("1337_BACKGRUND", "START");
//            this.params = params;
//            int count = params.length;
//            for (int i = 0; i < count; i++) {
////                try {
//                isFinished = params[i].calculateGameMapPixel();
////                    Thread.sleep(5000);
////                } catch (InterruptedException e) {
////                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
////                }
//            }
//            Log.i("1337_BACKGRUND", Boolean.toString(isFinished));
//            return isFinished;  //To change body of implemented methods use File | Settings | File Templates.
//        }
//
//        @Override
//        protected void onPostExecute(Boolean result) {
//            Log.i("1337_POSTEXE", Boolean.toString(result));
//            if (result) {
//                gameMapHelper.setPixelCalculationCompleted(true);
//            }
//        }
//    }
}
